<extend name="./public/frame.html"/>
<block name="content">
    <style>
        .layui-form-label{width: 10%;}
        .layui-input-block{margin-left: 12%;}
    </style>
    <form class="layui-form layui-form-pane1" action="" method="post" enctype="multipart/form-data">
        <table class="layui-table">
            <tr>
                <td style="width: 10%;text-align: center;">所在区域</td>
                <td>
                    <div class="layui-inline">
                        <div class="layui-input-inline" style="width: 200px;margin-right: 5px;">
                            <select name="province_id" id="province_id" lay-verify="required" lay-filter="province">
                                <option value="">请选择省份</option>
                                <?php foreach($provinceList as $key=>$value):?>
                                <option value="<?php echo $value['region_id'];?>" <if condition="$data.province_id eq $value['region_id']">selected</if> ><?php echo $value['region_name'];?></option>
                                <?php endforeach;?>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline" style="width: 200px;margin-right: 5px;">
                            <select name="city_id" id="city_id" lay-verify="required" lay-filter="city">
                                <option value="">请选择城市</option>
                                <?php foreach($cityList as $key=>$value):?>
                                <option value="<?php echo $value['region_id'];?>" <if condition="$data.city_id eq $value['region_id']">selected</if> ><?php echo $value['region_name'];?></option>
                                <?php endforeach;?>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline" style="width: 200px;margin-right: 5px;">
                            <select name="country_id" id="country_id" lay-verify="required" lay-filter="country_id">
                                <option value="">请选择地区</option>
                                <?php foreach($countryList as $key=>$value):?>
                                <option value="<?php echo $value['region_id'];?>" <if condition="$data.country_id eq $value['region_id']">selected</if> ><?php echo $value['region_name'];?></option>
                                <?php endforeach;?>
                            </select>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td style="width: 10%;text-align: center;">车队名称</td>
                <td>
                    <input type="text" name="name" lay-verify="required" placeholder="车队名称" value="{$data.name}" autocomplete="off" class="layui-input" style="width: 618px;">
                </td>
            </tr>
            <tr>
                <td style="width: 10%;text-align: center;">联系人</td>
                <td>
                    <input type="text" name="username" lay-verify="required" placeholder="联系人姓名" value="{$data.username}" autocomplete="off" class="layui-input" style="width: 618px;">
                </td>
            </tr>
            <tr>
                <td style="width: 10%;text-align: center;">手机号</td>
                <td>
                    <input type="text" name="phone" lay-verify="required" placeholder="联系电话" value="{$data.phone}" autocomplete="off" class="layui-input" style="width: 618px;">
                </td>
            </tr>
            <tr>
                <td style="width: 10%;text-align: center;">备注</td>
                <td><textarea placeholder="请输入备注" class="layui-textarea" name="content" style="width: 618px;">{$data.content}</textarea></td>
            </tr>
            <tr>
                <td colspan="2" style="padding-left: 100px;">
                    <button class="layui-btn" lay-submit lay-filter="submit">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </td>
            </tr>
        </table>
        <!--<div class="layui-form-item">
            <label class="layui-form-label">首次登录提成金额(分)</label>
            <div class="layui-input-block">
                <input type="text" name="first_login_money" placeholder="提成金额"
                       value="{$data.first_login_money}" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">首单提成方式</label>
            <div class="layui-input-block">
                <input type="radio" name="first_per_type" lay-filter="first_per_type" value="1" title="固定金额" <if condition="$data.first_per_type eq 1">checked</if> />
                <input type="radio" name="first_per_type" lay-filter="first_per_type" value="2" title="固定比例" <if condition="$data.first_per_type eq 2">checked</if> />
            </div>
        </div>

        <div class="layui-form-item" id="per_type_1" <if condition="$data.first_per_type eq 2">style="display:none"</if>>
            <label class="layui-form-label">首单提成金额(分)</label>
            <div class="layui-input-block">
                <input type="text" name="first_per_money" placeholder="提成金额"
                       value="{$data.first_per_money}" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item" id="per_type_2" <if condition="$data.first_per_type eq 1">style="display:none"</if>>
            <label class="layui-form-label">首单提成比例</label>
            <div class="layui-input-block">
                <input type="text" name="first_per_scale" placeholder="提成比例"
                       value="{$data.first_per_scale}" autocomplete="off" class="layui-input">
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">支付宝姓名</label>
            <div class="layui-input-block">
                <input type="text" name="alipay_name" placeholder="支付宝姓名"
                       value="{$data.alipay_name}" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">支付宝账号</label>
            <div class="layui-input-block">
                <input type="text" name="alipay_account" placeholder="支付宝账号"
                       value="{$data.alipay_account}" autocomplete="off" class="layui-input">
            </div>
        </div>
        -->
    </form>
    <script>
        /*get_city();
        function get_city(){
            $("#city_id").empty();
            $("#city_id").append('<option value=>请选择城市</option>');
            var province_id = $("#province_id").val();
            $.ajax({
                url:'{:url("/admin/Business/getCityList")}',
                async:true,
                //dataType:'json',
                type:'post',
                data:{'province_id':province_id},
                success:function(res){
                    $("#city_id").append(res);
                    form.render('select');
                },
                error:function(e){
                    layer.msg('请求错误');return false;
                }
            })
        }*/
        layui.use(['form'], function () {
            form = layui.form;
            form.on('select(province)', function(data){
                $("#city_id").empty();
                $("#city_id").append('<option value=>请选择城市</option>');
                var province_id = data.value;
                $.ajax({
                    url:'{:url("/admin/Business/getCityList")}',
                    async:true,
                    //dataType:'json',
                    type:'post',
                    data:{'province_id':province_id},
                    success:function(res){
                        $("#city_id").append(res);
                        form.render('select');
                    },
                    error:function(e){
                        layer.msg('请求错误');return false;
                    }
                })
            });
            form.on('select(city)', function(data){
                $("#country_id").empty();
                $("#country_id").append('<option value=>请选择地区</option>');
                var city_id = data.value;
                $.ajax({
                    url:'{:url("/admin/Business/getCountryList")}',
                    async:true,
                    //dataType:'json',
                    type:'post',
                    data:{'city_id':city_id},
                    success:function(res){
                        $("#country_id").append(res);
                        form.render('select');
                    },
                    error:function(e){
                        layer.msg('请求错误');return false;
                    }
                })
            });

            form.on('radio(first_per_type)', function(data){
                if(data.value == 1){
                    $("#per_type_1").show();
                    $("#per_type_2").hide();
                }else if(data.value == 2){
                    $("#per_type_1").hide();
                    $("#per_type_2").show();
                }
            });

            //监听提交
            form.on('submit(submit)', function (data) {

            });

        });
    </script>
</block>
